package com.itbaima.csmall.business.rabbit.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>RabbitMQConfig</p>
 *
 * @author Chen
 * @since 2023/3/8 19:07:07
 */
@Configuration
public class RabbitMQConfig {

    public static final String BIZ_EXCHANGE = "biz_ex";
    public static final String BIZ_ROUTE_KEY = "biz_route_key";
    public static final String BIZ_QUEUE = "biz_queue";

    @Bean
    public DirectExchange bizExchange() {
        return new DirectExchange(BIZ_EXCHANGE);
    }

    @Bean
    public Queue bizQueue() {
        return new Queue(BIZ_QUEUE, false, false, false, null);
    }

    @Bean
    public Binding bizBinding() {
        return BindingBuilder.bind(bizQueue()).to(bizExchange()).with(BIZ_ROUTE_KEY);
    }

}
